package cn.new7as.cas5s.anhjkfu;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.widget.DatePicker;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.util.XPopupUtils;

import cn.new7as.cas5s.R;

public class DatePop extends BottomPopupView {


    private Context context;

    public DatePop(@NonNull Context context) {
        super(context);

        this.context = context;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.layout_date;
    }

    OnConfirmListener xPopupCallback;

    public BasePopupView setPopupCallback(OnConfirmListener xPopupCallback) {
        this.xPopupCallback = xPopupCallback;

        return this;
    }


    String dates;

    @SuppressLint("NewApi")
    @Override
    protected void onCreate() {
        super.onCreate();

        TextView verifyme = findViewById(R.id.btn_ok);
        DatePicker datePicker = findViewById(R.id.dp_date);
        datePicker.init(2000, 0, 1, new DatePicker.OnDateChangedListener() {
            @Override
            public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                dates = dayOfMonth + "/" + (monthOfYear+1) + "/" + year;
            }
        });

        dates="2000/1/1";
        verifyme.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                xPopupCallback.onConfirm(dates);

            }
        });
    }


    @Override
    protected void onShow() {
        super.onShow();

    }




    @Override
    protected int getMaxHeight() {
        return (int) (XPopupUtils.getScreenHeight(getContext()) * .7f);
    }
}